<?php
/**
 * Created by PhpStorm.
 * User: paperen
 * Date: 2020/6/17
 * Time: 21:09
 */

namespace App\Repositories\Task;

use App\Repositories\Repository;
use Illuminate\Support\Facades\DB;


/**
 * Class TaskRequestRepository
 * @package App\Repositories\Task
 * @version v1.3
 */
class TaskRequestRepository extends Repository
{
	const STATE_ING = 1;
	const STATE_OVER = 2;
	const STATE_OVERTIME = 3;

	 /**
     * @return string
     */
    public function model()
    {
        return \App\Models\Task\TaskRequestModel::class;
    }

    public function getOvertime() {
    	$date = date('Y-m-d H:i:00');
		return $this->model
			->where('deadline', '<=', $date)
			->where('state', self::STATE_ING)
			->get();
	}

	public function setOvertime($id) {
		$date = date('Y-m-d H:i:00');
		return $this->model
			->where('deadline', '<=', $date)
			->where('state', self::STATE_ING)
			->update(['state' => self::STATE_OVERTIME]);
	}

}
